#include "dialog.h"
#include"ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);

    edit_row=new QLineEdit(this);
    edit_col=new QLineEdit(this);
    edit_bomb=new QLineEdit(this);

    label_row=new QLabel("行数：",this);
    label_col=new QLabel("列数：",this);
    label_bomb=new QLabel("炸弹数：",this);

    edit_row->move(150,30);
    edit_col->move(150,70);
    edit_bomb->move(150,110);

    label_row->move(100,30);
    label_col->move(100,70);
    label_bomb->move(100,110);

    makesure=new QPushButton("确定",this);
    makesure->move(150,150);
    //实现点击按钮后按照行列炸弹数初始化并关闭dialog
    connect(makesure,SIGNAL(clicked()),this,SLOT(makesureof()));

}
Dialog::~Dialog()
{
    delete ui;
}

void Dialog::setRows(int nRow)
{
    this->nRow=nRow;
}
void Dialog::setCols(int nColumn)
{
    this->nColumn=nColumn;
}
void Dialog::setBomb(int nBomb)
{
    this->nBomb=nBomb;
}

int Dialog::getRow()
{
    return nRow;
}
int Dialog::getCol()
{
    return nColumn;
}
int Dialog::getBomb()
{
    return nBomb;
}

void Dialog::makesureof()
{
    nRow=edit_row->text().toInt();
    nColumn=edit_col->text().toInt();
    nBomb=edit_bomb->text().toInt();

    emit(dia_test());

    this->close();
}
